#ifndef QUSERMANAGER_H
#define QUSERMANAGER_H

#include <QObject>

#include "sharedlibglobal.h"


#include <QList>

class QXmlStreamReader;

namespace SHAREDLIB
{

    class SHAREDLIB_EXPORT QUserManager : public QObject
    {
        Q_OBJECT
    public:
        explicit QUserManager(QObject *parent = 0);
        ~QUserManager();

        void        addUser(QObject* obj);
        void        inserUser(int index,QObject* obj);
        void        removeUser(const QString& userName);
        QObject*    getUser(int index);
        QObject*    getUser(const QString &userName);
        int         userIndex(QObject* obj);
        int         userCount();

        void        setUserName(QObject* obj,const QString& now);

        void        swapUser(int index1,int index2);

        void        setCurrentUser(const QString &userName);
        void        setCurrentUser(QObject* obj);
        QObject*    getCurrentUser();

        void        save(const QString &projectPath);
        void        load(const QString &projectPath);
        void        release();

    protected:
        void        loadUser(QXmlStreamReader *r);
    signals:
        void    currentUserChanged(QObject* current);
        void    userAdd(QObject* obj,int index);
        void    userDel(QObject* obj);
        void    userNameChanged(const QString &old,const QString& now);
    public slots:
    protected:
        QList<QObject*>     m_userList;
        QObject*            m_currentUser;
    };

}

#endif // QUSERMANAGER_H
